#include <stdio.h>
#include "typedef.h"
#include "bitmap.h"
#include "convert.h"
#include "threshold.h"

int main() {

  Bitmap src, gray, binary;
  unsigned char *buf, *yuv;
  FILE *fpw, *fpw2;
  int w, h, t;

  CheckPath("./test.bmp");
  ReadBitmap("./test.bmp", &src);

  t = threshold(&src);
  printf("%d\n", t);
  RGBToGray(&src, &gray);


  fpw = fopen("./gray.bmp", "wb");
  SaveBitmap("./gray.bmp", &gray);
  fclose(fpw);


  GrayToBinary(&gray, &binary, t);
  fpw2 = fopen("./binary.bmp", "wb");
  SaveBitmap("./binary.bmp", &binary);
  fclose(fpw2);

}